import axios from '@/utils/request'
import qs from 'qs'
import store from '@/store'

/**
 * 获取评论列表信息
 * @param {*} options tid 文章id
 * @returns
 */
const getComments = (options) => {
  const token = store.state.token
  let headers = {}
  if (token !== '') {
    headers = {
      headers: {
        Authorization: 'Bearer ' + store.state.token
      }
    }
  }
  return axios.get('/public/comments?' + qs.stringify(options), headers)
}

// 添加评论
const addComment = (data) => {
  return axios.post('/comments/reply', { ...data })
}

export {
  getComments, addComment
}
